<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var dog = {
            name: "可可",
            type: "阿拉斯加",
            age: 5,
            color: 'Red',
            skill: function() {
                console.log('bark');
                console.log('演电影');
            },
            average: function(a, b) {
                return ((a + b) / 2);
            }
        }
        console.log(dog);

        // //遍历对象
        for(var k in dog)
        {
            console.log(dog); //输出属性名 name type age color

        }
        // for (var k in dog) {
        //     console.log(dog[k]); //输出属性值 可可 阿拉斯加  18 red

        // }


        //在数组中遍历对象
        var data = [{
            name: '张可顺',
            subject: 'javascript',
            score: 90
        }, {
            name: '发展哥',
            subject: 'javascript',
            score: 99
        }, {
            name: '李金周',
            subject: 'javascript',
            score: 99
        }, {
            name: '孟磊',
            subject: 'javascript',
            score: 990
        }];
        var newobj = [];
        // for (var i = 0; i < data.length; i++) {
        //     for (var k in data[i]) {
        //         console.log(k);
        //         console.log(data[i][k]);
        //         newobj.push({
        //             [k]: data[i][k]
        //         })
        //     }

        // }
        data.forEach(item => {
            for (var k in item) {
                newobj.push(item[k])
            }

        })
        console.log(newobj);
    </script>


</head>

<body>

</body>

</html>